package Core;
/*
 *  J2Egn version 2.6.28
 *  Author: Van Tan Tai 2010-2011
 *  each of game page 
 */
import javax.microedition.lcdui.Graphics;

import Const.GConfig;

public class Slide {
	protected Sound sound = Sound.ins;
	public short id = 0;
	public int sizeW=GConfig.ScreenSize[0], sizeH=GConfig.ScreenSize[1];
	public int inX = 0, inY = 0, inW=0, inH=0;
	public Slide owned = null;
	public Slide subSl = null;
	private int hBar = 0;
	
	// Method
	protected void changeState(short newState){
		GLives.ins.setState(newState, false);
	}
	protected void changeSubState(short newState){
		if(subSl == null){
			GLives.ins.setState(newState, true);
		} else {
			GLives.ins.setState(subSl, true);
		}
	}
	protected void backSlide(){
		if(owned != null){
			GLives.ins.setState(owned, false);
		}
	}
	protected void exit(){
		GMain.gMidlet.destroyApp(true);
	}
	protected void drawString(Graphics g, String st, int x, int y, int align, int color){
		GLives.ins.bmf_normal.drawString(g, st, x, y, align, color);
	}
	protected void drawStringBold(Graphics g, String st, int x, int y, int align, int color){
		GLives.ins.bmf_bold.drawString(g, st, x, y, align, color);
	}
	public void setGameSize(int ww, int hh, int ihBar){
		hBar = ihBar;
		sizeW = ww;
		sizeH = hh;
		if(GLives.ScreenWidth > ww) {
			inW = ww;
			inX = (GLives.ScreenWidth - ww) >> 1;
		}
		else {
			inW = GLives.ScreenWidth;
			inX = 0;
		}
		if(GLives.ScreenHeight - ihBar > hh) {
			inH = hh;
			inY = (GLives.ScreenHeight - ihBar - hh)/2;
		}
		else {
			inH = GLives.ScreenHeight - ihBar;
			inY = 0;
		}
	}
	protected void executeInnerSize(){
		if(!GConfig.isStretchSize){
			setGameSize(sizeW, sizeH, hBar);
		}
		else {
			inX = inY = 0;
			inW = GLives.ScreenWidth;
			inH = GLives.ScreenHeight;
		}
		System.out.println("Game (" + inX + ", " + inY + ", " + inW + ", " + inH + ") - Full (" + GLives.ScreenWidth + ", " + GLives.ScreenHeight + ")");
	}
	protected void resetClip(Graphics g){
		g.setClip(0, 0, GLives.ScreenWidth, GLives.ScreenHeight);
	}
	// Event
	public void registerTouch(){
	}
	public void init(){
	}
	public void destroy(){
	}
	public void onResize(){
	}
	public void touchDrag(int x, int y) {
	}
	public void touchDown(int ID, int x, int y) {
	}
	public void touchUp(int ID, int x, int y) {
	}
	public void touchUp(int ID, int x, int y, int dragTime, int xBegin, int yBegin) {
	}
	public void Click(int ID, int x, int y) {
	}
	public void update(){
	}
	public void paint(Graphics g){
	}
	public void onkeyDown(int keyCode) {
	}
	public void onkeyUp(int keyCode) {
	}
}
